package com.mathassistant.client.view;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiTemplate;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.Widget;
import com.mathassistant.client.helper.ClickPoint;
import com.mathassistant.client.presenter.TopicPopupPresenter.Display;

public class TopicPopupView extends PopupPanel implements Display{

	@UiTemplate("TopicPopupView.ui.xml")
	interface TopicPopupViewUiBinder extends UiBinder<Widget, TopicPopupView> {
	}
	
	private static TopicPopupViewUiBinder uiBinder = GWT
	.create(TopicPopupViewUiBinder.class);
	
	@UiField Label titletopic;
	@UiField Button btEdit;
	@UiField Button btDelete;
	
	public TopicPopupView() {
		super(true);
		add(uiBinder.createAndBindUi(this));
	}

	public TopicPopupView(String title, ClickPoint point) {
		this();
		setTitleAndShow(title, point);
	}
	@Override
	public HasClickHandlers getEditButton() {
		// TODO Auto-generated method stub
		return btEdit;
	}

	@Override
	public HasClickHandlers getDeleteButton() {
		// TODO Auto-generated method stub
		return btDelete;
	}

	@Override
	public HasText getFriendNameLabel() {
		// TODO Auto-generated method stub
		return titletopic;
	}

	@Override
	public void hideDialog() {
		// TODO Auto-generated method stub
		this.hide();
	}

	@Override
	public void setTitle(String title) {
		// TODO Auto-generated method stub
		this.titletopic.setText(title);
	}

	@Override
	public void setTitleAndShow(String displayName, ClickPoint location) {
		// TODO Auto-generated method stub
		this.titletopic.setText(displayName);
		setPopupPosition(location.getLeft(), location.getTop());
		show();
	}

}
